{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
~}}

<Hds::SideNav::Portal @ariaLabel="Cluster Navigation Links" data-test-sidebar-nav-panel="Cluster" as |Nav|>
  <Nav.Title data-test-sidebar-nav-heading="Vault">Vault</Nav.Title>

  <Nav.Link @route="vault.cluster.dashboard" @text="Dashboard" data-test-sidebar-nav-link="Dashboard" />
  <Nav.Link
    @route="vault.cluster.secrets"
    @current-when="vault.cluster.secrets vault.cluster.settings.mount-secret-backend vault.cluster.settings.configure-secret-backend"
    @text="Secrets Engines"
    data-test-sidebar-nav-link="Secrets Engines"
  />
  {{#if (has-permission "access")}}
    <Nav.Link
      @route={{get (route-params-for "access") "route"}}
      @models={{get (route-params-for "access") "models"}}
      @current-when="vault.cluster.access vault.cluster.settings.auth"
      @text="Access"
      @hasSubItems={{true}}
      data-test-sidebar-nav-link="Access"
    />
  {{/if}}
  {{#if (has-permission "policies")}}
    <Nav.Link
      @route="vault.cluster.policies"
      @models={{get (route-params-for "policies") "models"}}
      @text="Policies"
      @hasSubItems={{true}}
      data-test-sidebar-nav-link="Policies"
    />
  {{/if}}
  {{#if (has-permission "tools")}}
    <Nav.Link
      @route="vault.cluster.tools.tool"
      @models={{get (route-params-for "tools") "models"}}
      @text="Tools"
      @hasSubItems={{true}}
      data-test-sidebar-nav-link="Tools"
    />
  {{/if}}

  {{#if
    (and
      this.version.isEnterprise
      this.namespace.inRootNamespace
      this.cluster.anyReplicationEnabled
      (has-permission "status" routeParams="replication")
    )
  }}
    <Nav.Title data-test-sidebar-nav-heading="Replication">Replication</Nav.Title>
    <Nav.Link
      @route="vault.cluster.replication.mode.index"
      @model="dr"
      @text="Disaster Recovery"
      data-test-sidebar-nav-link="Disaster Recovery"
    />

    {{#if (has-feature "Performance Replication")}}
      <Nav.Link
        @route="vault.cluster.replication.mode.index"
        @model="performance"
        @text="Performance"
        data-test-sidebar-nav-link="Performance"
      />
    {{/if}}
  {{/if}}

  {{#if
    (or
      (and
        this.namespace.inRootNamespace (has-permission "status" routeParams=(array "replication" "raft" "license" "seal"))
      )
      (has-permission "clients" routeParams="activity")
    )
  }}
    <Nav.Title data-test-sidebar-nav-heading="Monitoring">Monitoring</Nav.Title>
  {{/if}}
  {{#if (and this.version.isEnterprise this.namespace.inRootNamespace (has-permission "status" routeParams="replication"))}}
    <Nav.Link @route="vault.cluster.replication.index" @text="Replication" data-test-sidebar-nav-link="Replication" />
  {{/if}}
  {{#if (and this.cluster.usingRaft this.namespace.inRootNamespace (has-permission "status" routeParams="raft"))}}
    <Nav.Link
      @route="vault.cluster.storage"
      @model={{this.cluster.name}}
      @text="Raft Storage"
      data-test-sidebar-nav-link="Raft Storage"
    />
  {{/if}}
  {{#if (and (has-permission "clients" routeParams="activity") (not this.cluster.dr.isSecondary))}}
    <Nav.Link @route="vault.cluster.clients" @text="Client Count" data-test-sidebar-nav-link="Client Count" />
  {{/if}}
  {{#if
    (and
      this.version.features
      this.namespace.inRootNamespace
      (has-permission "status" routeParams="license")
      (not this.cluster.dr.isSecondary)
    )
  }}
    <Nav.Link
      @route="vault.cluster.license"
      @model={{this.cluster.name}}
      @text="License"
      data-test-sidebar-nav-link="License"
    />
  {{/if}}
  {{#if (and this.namespace.inRootNamespace (has-permission "status" routeParams="seal") (not this.cluster.dr.isSecondary))}}
    <Nav.Link
      @route="vault.cluster.settings.seal"
      @model={{this.cluster.name}}
      @text="Seal Vault"
      data-test-sidebar-nav-link="Seal Vault"
    />
  {{/if}}
</Hds::SideNav::Portal>